home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieZelluloid.py < prev   
Text File  |  2008-11-17  |  9KB  |  269 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieZelluloid.py 1042 2008-11-15 21:59:58Z mikej06 $'
  4.  
  5. # Copyright (c) 2007 Michael Jahn
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27. import re
  28.  
  29. plugin_name         = 'Zelluloid.de'
  30. plugin_description  = 'ZELLULOID.DE'
  31. plugin_url          = 'www.zelluloid.de'
  32. plugin_language     = _('German')
  33. plugin_author       = 'Michael Jahn'
  34. plugin_author_email = '<mikej06@hotmail.com>'
  35. plugin_version      = '1.1'
  36.  
  37. class Plugin(movie.Movie):
  38.     index_url = 'http://www.zelluloid.de/filme/index.php3?id='
  39.     
  40.     def __init__(self, id):
  41.         self.encode='iso-8859-1'
  42.         self.movie_id = id
  43.         self.url = "http://www.zelluloid.de/filme/details.php3?id=" + self.movie_id
  44.  
  45.     def initialize(self):
  46.         self.detail_page = self.page
  47.         self.url = self.index_url + self.movie_id
  48.         self.page = self.open_page(url=self.url)
  49.  
  50.     def get_image(self):
  51.         self.image_url = 'http://www.zelluloid.de/images/poster/' + gutils.trim(self.page, '<IMG SRC="/images/poster/', '"');
  52.  
  53.     def get_o_title(self):
  54.         self.o_title = gutils.trim(self.page, 'Originaltitel: ', '<BR>')
  55.         if self.o_title == '':
  56.             self.o_title = gutils.trim(self.page, '<title>', '|')
  57.  
  58.     def get_title(self):
  59.         self.title = gutils.trim(self.page, '<title>', '|')
  60.  
  61.     def get_director(self):
  62.         self.director = gutils.trim(self.detail_page, 'Regie', '</A>')
  63.  
  64.     def get_plot(self):
  65.         self.plot = gutils.trim(self.page, '<DIV CLASS=bigtext>', '</DIV>')
  66.         
  67.     def get_year(self):
  68.         self.year = ''
  69.         elements = string.split(self.detail_page, '/directory/az.php3?j')
  70.         elements[0] = ''
  71.         delimiter = ''
  72.         for element in elements:
  73.             if element <> '':
  74.                 self.year = self.year + delimiter + gutils.trim(element, '>', '<')
  75.                 delimiter = ', '
  76.  
  77.     def get_runtime(self):
  78.         self.runtime = gutils.trim(self.detail_page, 'ca. ', ' min');
  79.  
  80.     def get_genre(self):
  81.         self.genre = ''
  82.         elements = string.split(self.detail_page, '/directory/az.php3?g')
  83.         elements[0] = ''
  84.         delimiter = ''
  85.         for element in elements:
  86.             if element <> '':
  87.                 self.genre = self.genre + delimiter + gutils.trim(element, '>', '<')
  88.                 delimiter = ', '
  89.  
  90.     def get_cast(self):
  91.         self.cast = gutils.trim(self.detail_page, 'alt="Besetzung"', '<TD COLSPAN=')
  92.         self.cast = self.cast.replace('<A HREF=', '--flip--' + '<A HREF=')
  93.         self.cast = gutils.strip_tags(self.cast)
  94.         self.cast = gutils.after(self.cast, '>')
  95.         elements = self.cast.split('\n')
  96.         self.cast = ''
  97.         for element in elements:
  98.             elements2 = element.split("--flip--")
  99.             if len(elements2) > 1:
  100.                 self.cast += elements2[1] + '--flip--' + elements2[0] + '\n'
  101.             else:
  102.                 self.cast += element + '\n'
  103.         self.cast = string.replace(self.cast, '--flip--', _(' as ').encode('utf8'))
  104.  
  105.     def get_classification(self):
  106.         self.classification = gutils.trim(self.detail_page, 'FSK: ', '</TD>')
  107.         self.classification = re.sub('[,<].*', '', self.classification)
  108.  
  109.     def get_studio(self):
  110.         self.studio = gutils.strip_tags(gutils.trim(self.detail_page, 'alt="Produktion"', ' '))
  111.         if self.studio == '':
  112.             self.studio = gutils.trim(self.detail_page, 'alt="Produktion"', '</TABLE>')
  113.         self.studio = gutils.after(self.studio, '>')
  114.         self.studio = self.studio.replace('\n', ', ')
  115.         self.studio = re.sub('((^, )|(, $))', '', self.studio)
  116.         
  117.     def get_o_site(self):
  118.         self.o_site = ""
  119.  
  120.     def get_site(self):
  121.         self.site = "http://www.zelluloid.de/filme/details.php3?id=" + self.movie_id
  122.  
  123.     def get_trailer(self):
  124.         self.trailer = ""
  125.  
  126.     def get_country(self):
  127.         self.country = ''
  128.         elements = string.split(self.detail_page, '/directory/az.php3?l')
  129.         elements[0] = ''
  130.         delimiter = ''
  131.         for element in elements:
  132.             if element <> '':
  133.                 self.country = self.country + delimiter + gutils.trim(element, '>', '<')
  134.                 delimiter = ', '
  135.  
  136.     def get_rating(self):
  137.         self.rating = gutils.strip_tags(gutils.trim(self.page, 'User-Wertung:', '</TABLE>'))
  138.         self.rating = self.rating.replace('%', '')
  139.         self.rating = self.rating.replace(' ', '')
  140.         self.rating = self.rating.replace('\n', '')
  141.         try:
  142.             ratingint = round(float(self.rating) / 10.0)
  143.         except:
  144.             ratingint = 0
  145.         self.rating = str(ratingint)
  146.  
  147.     def get_notes(self):
  148.         self.notes = ""
  149.  
  150. class SearchPlugin(movie.SearchMovie):
  151.  
  152.     def __init__(self):
  153.         self.original_url_search   = "http://www.zelluloid.de/suche/index.php3?qstring="
  154.         self.translated_url_search = "http://www.zelluloid.de/suche/index.php3?qstring="
  155.         self.encode='iso-8859-1'
  156.         self.remove_accents = False
  157.  
  158.     def search(self,parent_window):
  159.         self.open_search(parent_window)
  160.         tmp = gutils.trim(self.page, "Der Suchbegriff erzielte", "</TABLE>")
  161.         return tmp
  162.  
  163.     def get_searches(self):
  164.         elements = string.split(self.page, "hit.php3?hit=")
  165.         elements[0] = ''
  166.         for element in elements:
  167.             if element <> '':
  168.                 id = gutils.trim(element, 'movie-', '-')
  169.                 if id <> '':
  170.                     self.ids.append(id)
  171.                     self.titles.append(gutils.strip_tags(string.replace(gutils.trim(element, '>', '</A>'), '<BR>', ' - ')))
  172.  
  173. #
  174. # Plugin Test
  175. #
  176. class SearchPluginTest(SearchPlugin):
  177.     #
  178.     # Configuration for automated tests:
  179.     # dict { movie_id -> [ expected result count for original url, expected result count for translated url ] }
  180.     #
  181.     test_configuration = {
  182.         'Rocky Balboa'        : [ 1, 1 ],
  183.         'Die wilden H├╝hner'    : [ 3, 3 ]
  184.     }
  185.  
  186. class PluginTest:
  187.     #
  188.     # Configuration for automated tests:
  189.     # dict { movie_id -> dict { arribute -> value } }
  190.     #
  191.     # value: * True/False if attribute only should be tested for any value
  192.     #        * or the expected value
  193.     #
  194.     test_configuration = {
  195.         '2835' : { 
  196.             'title'             : 'Rocky Balboa',
  197.             'o_title'             : 'Rocky Balboa',
  198.             'director'            : 'Sylvester Stallone',
  199.             'plot'                 : True,
  200.             'cast'                : 'Sylvester Stallone' + _(' as ') + 'Rocky Balboa\n\
  201. Burt Young' + _(' as ') + 'Paulie\n\
  202. Antonio Tarver' + _(' as ') + 'Mason Dixon\n\
  203. Geraldine Hughes' + _(' as ') + 'Marie\n\
  204. Milo Ventimiglia' + _(' as ') + 'Rocky Jr.\n\
  205. Tony Burton' + _(' as ') + 'Duke\n\
  206. A.J. Benza' + _(' as ') + 'L.C.\n\
  207. James Francis Kelly III' + _(' as ') + 'Steps\n\
  208. Talia Shire' + _(' as ') + 'Adrian\n\
  209. Lou DiBella' + _(' as ') + 'Lou DiBella\n\
  210. Mike Tyson' + _(' as ') + 'Mike Tyson\n\
  211. Henry G. Sanders' + _(' as ') + 'Martin',
  212.             'country'            : 'USA',
  213.             'genre'                : 'Drama, Sport',
  214.             'classification'    : 'ab 12',
  215.             'studio'            : 'Chartoff-Winkler Productions, Columbia Pictures Corporation, Metro-Goldwyn-Mayer, Revolution Studios, Rogue Marble',
  216.             'o_site'            : False,
  217.             'site'                : 'http://www.zelluloid.de/filme/details.php3?id=2835',
  218.             'trailer'            : False,
  219.             'year'                : 2006,
  220.             'notes'                : False,
  221.             'runtime'            : 102,
  222.             'image'                : True,
  223.             'rating'            : 8.0
  224.         },
  225.         '6342' : { 
  226.             'title'             : 'Die wilden H├╝hner',
  227.             'o_title'             : 'Die wilden H├╝hner',
  228.             'director'            : 'Vivian Naefe',
  229.             'plot'                 : True,
  230.             'cast'                : 'Michelle von Treuberg' + _(' as ') + 'Sprotte\n\
  231. Lucie Hollmann' + _(' as ') + 'Frieda\n\
  232. Paula Riemann' + _(' as ') + 'Melanie\n\
  233. Zsa Zsa Inci B├╝rkle' + _(' as ') + 'Trude\n\
  234. Jette Hering' + _(' as ') + 'Wilma\n\
  235. Jeremy Mockridge' + _(' as ') + 'Fred\n\
  236. Philip Wiegratz' + _(' as ') + 'Steve\n\
  237. Martin Kurz' + _(' as ') + 'Torte\n\
  238. Vincent Redetzki' + _(' as ') + 'Willi\n\
  239. Veronica Ferres' + _(' as ') + 'Sprottes Mutter Sibylle\n\
  240. Doris Schade' + _(' as ') + 'Oma Sl├ñttberg\n\
  241. Jessica Schwarz' + _(' as ') + 'Frau Rose\n\
  242. Benno F├╝rmann' + _(' as ') + 'Herr Gr├╝nbaum\n\
  243. Axel Prahl' + _(' as ') + 'Willis Vater\n\
  244. Lukas Steimel' + _(' as ') + 'Luki\n\
  245. Lukas Engel' + _(' as ') + 'Titus\n\
  246. Pino Severino Geyssen' + _(' as ') + 'Paolo\n\
  247. Christine Rose' + _(' as ') + 'Jutta\n\
  248. Herbert Meurer' + _(' as ') + 'Herr Feistkorn\n\
  249. Marius Fischer' + _(' as ') + 'Bo\n\
  250. Anya Hoffmann' + _(' as ') + 'Melanies Mutter\n\
  251. Frank Wickermann' + _(' as ') + 'Melanies Vater\n\
  252. Axel H├ñfner' + _(' as ') + 'Schrottplatzw├ñrter\n\
  253. Simon Gosejohann' + _(' as ') + 'junger Mann\n\
  254. Piet Klocke' + _(' as ') + 'Junggeselle',
  255.             'country'            : 'Deutschland',
  256.             'genre'                : 'Kinder',
  257.             'classification'    : 'ohne',
  258.             'studio'            : 'Bavaria Film, Constantin Film',
  259.             'o_site'            : False,
  260.             'site'                : 'http://www.zelluloid.de/filme/details.php3?id=6342',
  261.             'trailer'            : False,
  262.             'year'                : 2006,
  263.             'notes'                : False,
  264.             'runtime'            : 109,
  265.             'image'                : True,
  266.             'rating'            : 8.0
  267.         }
  268.     }
  269.